package com.community.process._1010.dao.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.community.process._1010.dao.entity.ProcessIngredients;
import com.community.process._1010.dao.mapper.ProcessIngredientsMapper;
import com.community.process._1010.dao.service.ProcessIngredientsIService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 到餐加工食材 服务实现类
 *
 * @author Zbs
 * @since 2024-09-05
 */
@Service
public class ProcessIngredientsIServiceImpl extends ServiceImpl<ProcessIngredientsMapper, ProcessIngredients> implements ProcessIngredientsIService {
    @Override
    public List<ProcessIngredients> findByIdIn(List<Long> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return new ArrayList<>();
        }
        return this.listByIds(ids);
    }

    @Override
    public Map<Long, ProcessIngredients> findByIdInToMap(List<Long> ids) {
        return this.findByIdIn(ids).stream().collect(Collectors.toMap(ProcessIngredients::getId, a -> a));
    }
}
